<template>
  <section>
    <ul class="radio-group">
      <li class="radio-button" :class="value===item.value?'active':''" v-for="item in selectList"
          @click="changeValue(item.value)">
        <el-tooltip class="item" effect="light" :content="item.text" placement="bottom">
          <i class="radio-icon" :class="item.icon" v-if="item.icon&&!item.img"></i>
          <img v-if="item.img&&!item.icon" :src="item.img"/>
          <span v-if="!item.img&&!item.icon">{{ item.text }}</span>
        </el-tooltip>
      </li>
    </ul>
  </section>
</template>

<script>
export default {
  name: "select-item",
  data() {
    return {
    }
  },
  props: {
    selectList: {//[{value:"",icon:"",img:"",text:""}]
      type: Array,
      default: () => {
        return [];
      }
    },
    value:{
    	type:[String, Number],
      default:""
    }
  },
  methods: {
    changeValue(val) {
      this.$emit('input', val);
      this.$emit('change', val);
    }
  },
  mounted() {
  }
}
</script>

<style lang="scss" scoped>
.radio-group {
  display: flex;
  align-items: center;
  width: 100%;
  border-radius: 2px;

  & > li {
    flex: 1;
    flex-shrink: 0;
    text-align: center;
    border: 1px solid #dcdee0;
    height: 32px;
    font-weight: 500;
    line-height: 30px;
    transition: all .3s;
    appearance: none;
    cursor: pointer;
    position: relative;
    color: #999;
    .el-tooltip:focus{
      outline: none;
    }

    &:not(:first-child) {
      margin-left: -1px;
    }

    .text {

    }

    .radio-icon {
      font-size: 18px;
    }

    & > img {
      width: 20px;
      height: 20px;
    }
  }

  & > li.active {
    background-color: #e0edff;
    border-color: #155bd4;
    color: #155bd4;
    z-index: 2;
  }

  & > li:first-child {
    border-radius: 2px 0 0 2px;
  }

  & > li:last-child {
    border-radius: 0 2px 2px 0;
  }
}
</style>
<style>
.el-tooltip__popper.is-light {
  border: none;
  box-shadow: 0 0 4px 0 rgba(10, 42, 97, .2);

}

.el-tooltip__popper .popper__arrow {
  border: 1px solid #eee !important;
}
</style>
